﻿using System;
using DemoPathfinding.Hotfix.Components;
using ETHotfix;
using ETModel;

namespace DemoPathfinding.Hotfix.Handlers {
    [MessageHandler(AppType.Gate)]
    public class R2G_GetLoginKeyHandler : AMRpcHandler<R2G_GetLoginKey, G2R_GetLoginKey> {
        protected override void Run(Session session, R2G_GetLoginKey message, Action<G2R_GetLoginKey> reply) {
            G2R_GetLoginKey response = new G2R_GetLoginKey();
            try {
                response.GateLoginKey = Game.Scene.GetComponent<GateLoginKeyComponent>().BuildGateLoginKey(message.UserAccount);
                reply(response);
            } catch (Exception e) {
                ReplyError(response, e, reply);
            }
        }
    }
}